In [1]:
import numpy as np
import matplotlib
import matplotlib.pyplot as plt
import glob
import os
import pandas as pd
import plotly
import plotly.express as px
import plotly.io as pio
import plotly.graph_objects as go
In [2]:
def setup_plotly(fig):
fig.update_layout(
#title="PL",
#use this to adjust legend position, x y is relative positon to tghe plot
#legend=dict(x=0.8,y=0.96, traceorder='normal',font=dict(size=28)),
# change rgb and transparency of paper background
paper_bgcolor='rgba(255,255,255,1)',
plot_bgcolor='rgba(0,0,0,0)',
width = 1000,
height = 800,
xaxis_title="Wavelength (nm)",
yaxis_title="PL intensity (arb. unit)",
#xaxis_range=[0.75,5.25],
#yaxis_range=[1.5,7.5],
#legend_title="Legend Titley",
xaxis=dict(showgrid=False,linewidth=3, linecolor='black', mirror=True,
ticks='inside', tickwidth=3, tickfont=dict(size=28),
title=dict(font=dict(size=36)),
showline=True,minor=dict(nticks=2,ticks='inside',tickwidth=2)),
yaxis=dict(showgrid=False,linewidth=3, linecolor='black', mirror=True,
ticks='inside', tickwidth=3, tickfont=dict(size=28),
title=dict(font=dict(size=36)),
showline=True,minor=dict(nticks=2,ticks='inside',tickwidth=2))
)
fig.update_traces(mode="lines+markers",line=dict( width=5))
In [3]:
import plotly.graph_objects as go
x = [1, 2, 3, 4, 5]
y1 = [6, 7, 2, 4, 5]
y2 = [2, 3, 4, 5, 6]
y3 = [4, 5, 5, 7, 2]
fig = go.Figure()
fig.add_trace(go.Scatter(x=x, y=y1,
name="Temp."
))
fig.add_trace(go.Scatter(x=x, y=y2,
name="Rate"
))
fig.add_trace(go.Scatter(x=x, y=y3,
name="Objects"
))
'''
#might be useful for adjusting
fig.update_layout(
#title="PL",
xaxis_title="Wavelength (nm)",
yaxis_title="PL intensity (arb. unit)",
xaxis_range=[550,1000],
yaxis_range=[0,4000],
)
'''
setup_plotly(fig)
fig.show()
#fig.write_html("plotly_examplt.html")
In [ ]:
from IPython.display import IFrame
IFrame(src='/content/drive/MyDrive/resource/custom_filename.html', width=1100, height=900)
In [ ]:
In [4]:
from bokeh.plotting import figure, show
from bokeh.io import output_notebook
In [6]:
from bokeh.plotting import figure, show,output_file, save
# prepare some data
x = [1, 2, 3, 4, 5]
y1 = [6, 7, 2, 4, 5]
y2 = [2, 3, 4, 5, 6]
y3 = [4, 5, 5, 7, 2]
# create a new plot with a title and axis labels
p = figure()
# add multiple renderers
p.line(x, y1, legend_label="Temp.", color="blue", line_width=4)
p.line(x, y2, legend_label="Rate", color="red", line_width=4)
p.line(x, y3, legend_label="Objects", color="green", line_width=4)
p.grid.visible = False
p.xaxis.axis_label_text_font ="bold" # ?
p.xaxis.axis_label_text_font ="normal" # ?
p.xaxis.axis_label = "xlabel"
p.yaxis.axis_label = "ylabel"
p.width=1000
p.height=800
#p.line_width=4
p.xaxis.ticker.num_minor_ticks=2
p.yaxis.ticker.num_minor_ticks=2
p.outline_line_width=3
p.outline_line_alpha =1
p.outline_line_color = "black"
p.axis.minor_tick_in = 4
p.axis.minor_tick_out = 0
p.axis.major_tick_in = 6
p.axis.major_tick_out = 0
p.axis.major_tick_line_width = 3
p.axis.minor_tick_line_width = 3
p.axis.axis_label_text_font_size="48pt"
p.axis.major_label_text_font_size="36pt"
p.legend.label_text_font_size = '20pt'
# show the results
show(p)
#output_file(filename="/content/drive/MyDrive/resource/custom_filename.html")
#save(p)
In [ ]: